package com.jack.leetcode.array;

/*** 
 * @author zhangjie
 * @date 2020/3/23 21:50
 */
public class 删除排序数组中的重复项 {

    public static void main(String[] args) {
        int nums[] = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(nums));
    }

    public static int removeDuplicates(int[] nums) {
        int p = 0;
        int q = 1;
        while(q < nums.length){
            if(nums[p]!=nums[q]){
                nums[++p] = nums[q];
            }
            q++;
        }
        return p+1;
    }
}
